<template>
  <div v-loading="loading">
    <a-card>
      <title-name title="成本分析表" />
      <table
        v-if="state !== 3"
        class="tab6"
      >
        <thead>
          <tr>
            <th >序号</th>
            <th colSpan="2">
              费用项目
            </th>
            <th colSpan="3">
              测算成本（万元）
            </th>
            <th>备注</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td rowSpan="7">
              一
            </td>
            <td rowSpan="7">
              实体工程量清单费用
            </td>
            <td rowSpan="5">
              自行施工部分
            </td>
            <td colSpan="2">
              劳务费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[0].children[0].children[0].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[0].children[0].children[0].remarks" />
            </td>
          </tr>
          <tr>
            <td rowSpan="3">
              材料费
            </td>
            <td>钢筋</td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[0].children[0].children[1].children[0].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[0].children[0].children[1].children[0].remarks" />
            </td>
          </tr>
          <!--<tr>-->
          <!--<td>砼</td>-->
          <!--<td>-->
          <!--<BaseInputNumber-->
          <!--v-model="form6.analysisItems[0].children[0].children[1].children[1].costValue"-->
          <!--:precision="2"-->
          <!--/>-->
          <!--</td>-->
          <!--<td>-->
          <!--<BaseInput v-model="form6.analysisItems[0].children[0].children[1].children[1].remarks" />-->
          <!--</td>-->
          <!--</tr>-->
          <tr>
            <td>砼</td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[0].children[0].children[1].children[1].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[0].children[0].children[1].children[1].remarks" />
            </td>
          </tr>
          <tr>
            <td>其他</td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[0].children[0].children[1].children[2].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[0].children[0].children[1].children[2].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="2">
              施工机械使用费
            </td>

            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[0].children[0].children[2].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[0].children[0].children[2].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              专业分包
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[0].children[1].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[0].children[1].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td rowSpan="16">
              二
            </td>
            <td rowSpan="16">
              措施费
            </td>
            <td colSpan="3">
              安全文明施工（含环境保护、文明施工、安全施工、临时设施）
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[0].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[0].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              砼模板及支架费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[1].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[1].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              脚手架费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[2].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[2].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              夜间施工增加费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[3].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[3].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              二次搬运
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[4].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[4].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              冬雨季施工
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[5].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[5].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              工程定位复测费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[6].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[6].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              大型机械设备进出场及安拆
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[7].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[7].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              施工排水
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[8].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[8].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              施工降水
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[9].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[9].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              地上、地下设施，建筑物的临时保护设施
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[10].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[10].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              已完工程及设备保护
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[1].children[11].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[1].children[11].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>三</td>
            <td colSpan="4">
              管理费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[2].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[2].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td rowSpan="3">
              四
            </td>
            <td rowSpan="3">
              其他项目
            </td>
            <td colSpan="3">
              暂列金额
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[3].children[0].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[3].children[0].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              暂估金额
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[3].children[1].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[3].children[1].remarks" />
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              指定金额
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[3].children[2].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[3].children[2].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>五</td>
            <td colSpan="4">
              规费
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[4].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[4].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>六</td>
            <td colSpan="4">
              税金
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[5].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[5].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>七</td>
            <td colSpan="4">
              其他费用
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[6].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[6].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>八</td>
            <td colSpan="4">
              资金成本
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[7].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[7].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>九</td>
            <td colSpan="4">
              成本合计
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[8].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[8].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>十</td>
            <td colSpan="4">
              自行完成合同额（万元）
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[9].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[9].remarks" />
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>十一</td>
            <td colSpan="4">
              不含税利润率
            </td>
            <td>
              <BaseInputNumber
                v-model="form6.analysisItems[10].costValue"
                :precision="2"
              />
            </td>
            <td>
              <BaseInput v-model="form6.analysisItems[10].remarks" />
            </td>
          </tr>
        </tbody>
      </table>
      <table
        v-else
        class="tab6"
      >
        <thead>
          <tr>
            <th width="5%">
              序号
            </th>
            <th
              width="20%"
              colSpan="2"
            >
              费用项目
            </th>
            <th
              width="55%"
              colSpan="3"
            >
              测算成本（万元）
            </th>
            <th width="20%">
              备注
            </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td rowSpan="7">
              一
            </td>
            <td rowSpan="7">
              实体工程量清单费用
            </td>
            <td rowSpan="5">
              自行施工部分
            </td>
            <td colSpan="2">
              劳务费
            </td>
            <td width="20%">
              {{ form6.analysisItems[0].children[0].children[0].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[0].children[0].children[0].remarks }}
            </td>
          </tr>
          <tr>
            <td rowSpan="3">
              材料费
            </td>
            <td>钢筋</td>
            <td>
              {{ form6.analysisItems[0].children[0].children[1].children[0].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[0].children[0].children[1].children[0].remarks }}
            </td>
          </tr>
          <!--<tr>-->
          <!--<td>砼</td>-->
          <!--<td>-->
          <!--{{ form6.analysisItems[0].children[0].children[1].children[1].costValue }}-->
          <!--</td>-->
          <!--<td>-->
          <!--{{ form6.analysisItems[0].children[0].children[1].children[1].remarks }}-->
          <!--</td>-->
          <!--</tr>-->
          <tr>
            <td>砼</td>
            <td>
              {{ form6.analysisItems[0].children[0].children[1].children[1].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[0].children[0].children[1].children[1].remarks }}
            </td>
          </tr>
          <tr>
            <td>其他</td>
            <td>
              {{ form6.analysisItems[0].children[0].children[1].children[2].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[0].children[0].children[1].children[2].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="2">
              施工机械使用费
            </td>
            <td>
              {{ form6.analysisItems[0].children[0].children[2].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[0].children[0].children[2].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              专业分包
            </td>
            <td>
              {{ form6.analysisItems[0].children[1].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[0].children[1].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td rowSpan="16">
              二
            </td>
            <td rowSpan="16">
              措施费
            </td>
            <td colSpan="3">
              安全文明施工（含环境保护、文明施工、安全施工、临时设施）
            </td>
            <td>
              {{ form6.analysisItems[1].children[0].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[0].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              砼模板及支架费
            </td>
            <td>
              {{ form6.analysisItems[1].children[1].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[1].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              脚手架费
            </td>
            <td>
              {{ form6.analysisItems[1].children[2].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[2].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              夜间施工增加费
            </td>
            <td>
              {{ form6.analysisItems[1].children[3].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[3].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              二次搬运
            </td>
            <td>
              {{ form6.analysisItems[1].children[4].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[4].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              冬雨季施工
            </td>
            <td>
              {{ form6.analysisItems[1].children[5].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[5].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              工程定位复测费
            </td>
            <td>
              {{ form6.analysisItems[1].children[6].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[6].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              大型机械设备进出场及安拆
            </td>
            <td>
              {{ form6.analysisItems[1].children[7].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[7].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              施工排水
            </td>
            <td>
              {{ form6.analysisItems[1].children[8].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[8].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              施工降水
            </td>
            <td>
              {{ form6.analysisItems[1].children[9].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[9].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              地上、地下设施，建筑物的临时保护设施
            </td>
            <td>
              {{ form6.analysisItems[1].children[10].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[10].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              已完工程及设备保护
            </td>
            <td>
              {{ form6.analysisItems[1].children[11].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[1].children[11].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>三</td>
            <td colSpan="4">
              管理费
            </td>
            <td>
              {{ form6.analysisItems[2].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[2].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td rowSpan="3">
              四
            </td>
            <td rowSpan="3">
              其他项目
            </td>
            <td colSpan="3">
              暂列金额
            </td>
            <td>
              {{ form6.analysisItems[3].children[0].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[3].children[0].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              暂估金额
            </td>
            <td>
              {{ form6.analysisItems[3].children[1].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[3].children[1].remarks }}
            </td>
          </tr>
          <tr>
            <td colSpan="3">
              指定金额
            </td>
            <td>
              {{ form6.analysisItems[3].children[2].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[3].children[2].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>五</td>
            <td colSpan="4">
              规费
            </td>
            <td>
              {{ form6.analysisItems[4].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[4].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>六</td>
            <td colSpan="4">
              税金
            </td>
            <td>
              {{ form6.analysisItems[5].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[5].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>七</td>
            <td colSpan="4">
              其他费用
            </td>
            <td>
              {{ form6.analysisItems[6].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[6].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>八</td>
            <td colSpan="4">
              资金成本
            </td>
            <td>
              {{ form6.analysisItems[7].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[7].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>九</td>
            <td colSpan="4">
              成本合计
            </td>
            <td>
              {{ form6.analysisItems[8].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[8].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>十</td>
            <td colSpan="4">
              自行完成合同额（万元）
            </td>
            <td>
              {{ form6.analysisItems[9].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[9].remarks }}
            </td>
          </tr>
        </tbody>

        <tbody>
          <tr>
            <td>十一</td>
            <td colSpan="4">
              不含税利润率
            </td>
            <td>
              {{ form6.analysisItems[10].costValue }}
            </td>
            <td>
              {{ form6.analysisItems[10].remarks }}
            </td>
          </tr>
        </tbody>
      </table>
      <a-form-model
        ref="ruleForm"
        style="margin-top: 20px"
        :model="form6"
        :rules="form6Rules"
      >
        <a-row>
          <a-col span="8">
            <a-form-model-item label="填报人">
              <a-input
                v-model="form6.fillByName"
                disabled
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="填报日期">
              <a-date-picker
                v-model="form6.fillDate"
                disabled
              />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-card>
    <attachment
      :attachment="form6.fileInfos"
      :disabled="state !== 3"
      @change="(e) => (form6.fileInfos = e)"
    />
    <div
      v-if="state !== 3"
      class="operation page-btn-right-top"
    >
      <template v-if="form6.costAnalysis !== 'SUBMITTED'">
        <a-button
          v-if="form6.costAnalysis == 'REJECTED'"
          type="primary"
          class="mr20p"
          @click="save(form6.costAnalysis)"
        >
          保存草稿
        </a-button>
        <a-button
          v-else
          type="primary"
          class="mr20p"
          @click="save('DRAFT')"
        >
          保存草稿
        </a-button>
        <a-button
          type="primary"
          class="mr20p"
          @click="save('SUBMITTED')"
        >
          提交
        </a-button>
      </template>
      <a-button @click="$close()">
        关闭
      </a-button>
    </div>
    <selectApprover :businessId="businessId"  :processConfig="setProcessConfig"></selectApprover>
  </div>
</template>

<script>
import totalPackageContractApi from '@/api/legal/branchContract/totalPackageContract'
import attachment from './attachment'
import moment from 'moment'
export default {
    name: 'CostAnalysisTable',
    components: {
        attachment
    },
    props: {
        baseForm: {
            type: Object,
            default() {
                return {}
            }
        },
        id: {
            type: [String, Number],
            default() {
                return ''
            }
        },
        state: {
            type: Number,
            default() {
                return 1
            }
        },
        isAudit: {
            type: Boolean,
            default() {
                return false
            }
        }
    },
    data() {
        return {
            loading: false,
            formData: {},
            form6: {
                fillDate: moment().format('YYYY-MM-DD'),
                fillByName: JSON.parse(sessionStorage.getItem('ycloud-user_info')).name,
                fillByEmployeeId: '',
                fileInfos: [],
                analysisItems: [
                    {
                        id: '659279223449587712',
                        name: '实体工程量清单费用',
                        enabled: 'FALSE',
                        code: '3001',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 1,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: [
                            {
                                id: '659280738646102016',
                                name: '自行施工部分',
                                enabled: 'FALSE',
                                code: '300101',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 1,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: [
                                    {
                                        id: '659280952773709824',
                                        name: '劳务费',
                                        enabled: 'FALSE',
                                        code: '30010101',
                                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                        parentId: null,
                                        sortNum: 1,
                                        baseId: null,
                                        remarks: null,
                                        costValue: null,
                                        analysisId: null,
                                        children: null,
                                        parent: null
                                    },
                                    {
                                        id: '659281004493672448',
                                        name: '材料费',
                                        enabled: 'FALSE',
                                        code: '30010102',
                                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                        parentId: null,
                                        sortNum: 2,
                                        baseId: null,
                                        remarks: null,
                                        costValue: null,
                                        analysisId: null,
                                        children: [
                                            {
                                                id: '659281230767984640',
                                                name: '钢筋',
                                                enabled: 'FALSE',
                                                code: '3001010201',
                                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                                parentId: null,
                                                sortNum: 1,
                                                baseId: null,
                                                remarks: null,
                                                costValue: null,
                                                analysisId: null,
                                                children: null,
                                                parent: null
                                            },
                                            // {
                                            //     id: '659281263978483712',
                                            //     name: '砼',
                                            //     enabled: 'FALSE',
                                            //     code: '3001010202',
                                            //     type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                            //     parentId: null,
                                            //     sortNum: 2,
                                            //     baseId: null,
                                            //     remarks: null,
                                            //     costValue: null,
                                            //     analysisId: null,
                                            //     children: null,
                                            //     parent: null
                                            // },
                                            {
                                                id: '659281322686156800',
                                                name: '砼',
                                                enabled: 'FALSE',
                                                code: '3001010203',
                                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                                parentId: null,
                                                sortNum: 3,
                                                baseId: null,
                                                remarks: null,
                                                costValue: null,
                                                analysisId: null,
                                                children: null,
                                                parent: null
                                            },
                                            {
                                                id: '659285634539720704',
                                                name: '其他',
                                                enabled: 'FALSE',
                                                code: '3001010204',
                                                type: 'SUB_CONTRACT_METHOD',
                                                parentId: null,
                                                sortNum: 4,
                                                baseId: null,
                                                remarks: null,
                                                costValue: null,
                                                analysisId: null,
                                                children: null,
                                                parent: null
                                            }
                                        ],
                                        parent: null
                                    },
                                    {
                                        id: '659281044444418048',
                                        name: '施工机械使用费',
                                        enabled: 'FALSE',
                                        code: '30010103',
                                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                        parentId: null,
                                        sortNum: 3,
                                        baseId: null,
                                        remarks: null,
                                        costValue: null,
                                        analysisId: null,
                                        children: null,
                                        parent: null
                                    }
                                ],
                                parent: null
                            },
                            {
                                id: '659280816228143104',
                                name: '专业分包',
                                enabled: 'FALSE',
                                code: '300102',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 2,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            }
                        ],
                        parent: null
                    },
                    {
                        id: '659279505160015872',
                        name: '措施费',
                        enabled: 'FALSE',
                        code: '3002',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 2,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: [
                            {
                                id: '659281490349264896',
                                name: '安全文明施工（含环境保护、文明施工、安全施工、临时设施）',
                                enabled: 'FALSE',
                                code: '300201',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 1,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281555038015488',
                                name: '砼模板及支架费',
                                enabled: 'FALSE',
                                code: '300202',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 2,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281599099179008',
                                name: '脚手架费',
                                enabled: 'FALSE',
                                code: '300203',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 3,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281641822359552',
                                name: '二次搬运',
                                enabled: 'FALSE',
                                code: '300204',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 4,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281722709512192',
                                name: '大型机械设备进出场及安拆',
                                enabled: 'FALSE',
                                code: '300206',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 6,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281765835345920',
                                name: '施工排水',
                                enabled: 'FALSE',
                                code: '300207',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 7,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281817681137664',
                                name: '施工降水',
                                enabled: 'FALSE',
                                code: '300208',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 8,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281860685336576',
                                name: '地上、地下设施，建筑物的临时保护设施',
                                enabled: 'FALSE',
                                code: '300209',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 9,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659281960568492032',
                                name: '已完工程及设备保护',
                                enabled: 'FALSE',
                                code: '300210',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 10,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282000070447104',
                                name: '垃圾清运费',
                                enabled: 'FALSE',
                                code: '300211',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 11,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282042785239040',
                                name: '资料费',
                                enabled: 'FALSE',
                                code: '300212',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 12,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282233957421056',
                                name: '环境保护费',
                                enabled: 'FALSE',
                                code: '300216',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 16,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            }
                        ],
                        parent: null
                    },
                    {
                        id: '659279604774735872',
                        name: '管理费',
                        enabled: 'FALSE',
                        code: '3003',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 3,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659279645639839744',
                        name: '其他项目',
                        enabled: 'FALSE',
                        code: '3004',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 4,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: [
                            {
                                id: '659282392636329984',
                                name: '暂列金额',
                                enabled: 'FALSE',
                                code: '300401',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 1,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282440996655104',
                                name: '暂估金额',
                                enabled: 'FALSE',
                                code: '300402',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 2,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            },
                            {
                                id: '659282483136827392',
                                name: '指定金额',
                                enabled: 'FALSE',
                                code: '300403',
                                type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                                parentId: null,
                                sortNum: 3,
                                baseId: null,
                                remarks: null,
                                costValue: null,
                                analysisId: null,
                                children: null,
                                parent: null
                            }
                        ],
                        parent: null
                    },
                    {
                        id: '659279693127749632',
                        name: '规费目',
                        enabled: 'FALSE',
                        code: '3005',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 5,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659279736844980224',
                        name: '税金',
                        enabled: 'FALSE',
                        code: '3006',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 6,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659279777672335360',
                        name: '其他费用',
                        enabled: 'FALSE',
                        code: '3007',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 7,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659279820970135552',
                        name: '资金成本',
                        enabled: 'FALSE',
                        code: '3008',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 8,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659279932173717504',
                        name: '成本合计',
                        enabled: 'FALSE',
                        code: '3009',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 9,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659279994412994560',
                        name: '自行完成合同额',
                        enabled: 'FALSE',
                        code: '3010',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 10,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    },
                    {
                        id: '659280049614229504',
                        name: '不含税利润率',
                        enabled: 'FALSE',
                        code: '3011',
                        type: 'GENERAL_CONTRACT_COST_ANALYSIS',
                        parentId: null,
                        sortNum: 11,
                        baseId: null,
                        remarks: null,
                        costValue: null,
                        analysisId: null,
                        children: null,
                        parent: null
                    }
                ]
            },
            form6Rules: {
                fillDate: [{ required: true, message: '请选择填报日期', trigger: 'change' }]
            },
            localId: '',
            businessId: this.$route.query.businessId,
            //获取流程配置值
            processConfig: null,
            //点击提交发送流程配置值
            setProcessConfig: null,
            businessId: null
         }
    },
   async created() {
        this.localId = this.id || this.baseForm.baseId

        //获取通过获取流程配置值
       this.processConfig = await this.$getConfigFn('legal_general_costanalysis');
        this.getData()
    },
    methods: {
        async getData() {
            if (this.localId || this.$route.query.businessId) {
                this.loading = true
                let res = await totalPackageContractApi.findGeneralContractCostAnalysisByBaseId(
                    {},
                    {
                        baseId: this.isAudit ? '' : this.localId,
                        businessId: this.$route.query.businessId,
                        edit: this.state !== 3
                    }
                )
                if (res.code === 200) {
                    // this.form6 = this.$assign(res.data, this.form6)
                    this.form6 = res.data;
                    this.form6.fillDate = this.form6.fillDate || moment().format('YYYY-MM-DD')
                    this.form6.fillByName =
                        this.form6.fillByName || JSON.parse(sessionStorage.getItem('ycloud-user_info')).name
                    this.form6.fillByEmployeeId =
                        this.form6.fillByEmployeeId ||
                        JSON.parse(sessionStorage.getItem('ycloud-user_info')).employee.userId
                    this.$bus.$emit('getBaseInfo', this.form6.baseId)
                    if (!res.data.analysisItems) {
                        let res1 = await totalPackageContractApi.findGeneralContractCostAnalysisLabel()
                        if (res1.code === 200) {
                            this.form6.analysisItems = res1.data
                        }
                    }
                }
                this.loading = false
            }
        },
        // async submit() {
        //     if (!(await this.save('DRAFT'))) {
        //         return
        //     }
        //     // this.$bus.$emit('submit', '1106', '0')
        // },
        async save(status) {
            this.setProcessConfig = null; 
            this.$console(this.form6)
            this.submitApprovalConfirm(status == 'SUBMITTED'?this.processConfig:6,(flag)=>{
            if(!flag) {
                this.loading = false
                return
              }
              return new Promise((resolve) => {
                this.$refs.ruleForm.validate(async (valid, object) => {
                    if (valid) {
                        this.loading = true
                        this.form6.baseId = this.localId
                        this.form6.costAnalysis = status
                        this.form6.fillByName = JSON.parse(sessionStorage.getItem('ycloud-user_info')).name
                        this.form6.fillByEmployeeId = JSON.parse(
                            sessionStorage.getItem('ycloud-user_info')
                        ).employee.userId
                        let res = await totalPackageContractApi.updateGeneralContractCostAnalysis(this.form6)
                        if (res.code === 200) {
                            if (status === 'SUBMITTED') {
                                this.$noticeSuccess('提交成功')
                                //提交时，返回id
                                this.businessId = res.data?.businessId;
                                this.setProcessConfig = this.processConfig;
                                //this.$multiTab.close(this.$route.fullpath)
                            } else {
                                this.getData()
                                resolve(true)
                                this.$noticeSuccess('保存成功')
                            }
                        }
                        this.loading = false
                    } else {
                      this.$message.warning("请填写完所有必填项信息")
                    }
                })
            })
            })
  
        }
    }
}
</script>

<style lang="less" scoped>
table {
    width: 100%;
    border: 1px solid gainsboro;

    thead {
        background: rgb(244, 244, 244);

        th {
            padding: 10px;
            border: 1px solid gainsboro;
        }
    }

    tbody {
        td {
            padding: 10px;
            border: 1px solid gainsboro;
        }
    }
}
</style>
